package com.yumeng.common.runtime;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;


/**
 * @author wxd
 * @date 2022/8/25 13:53
 */
@Component
public class EnvironmentHelper {

    private static EnvironmentHelper environmentHelper;

    @Autowired
    private Environment environment;

    @PostConstruct
    public void init() {
        environmentHelper = this;
        environmentHelper.environment = this.environment;
    }

    public static String getValue(String key){
        return environmentHelper.environment.getProperty(key);
    }

    public static boolean containsKey(String key){
        return environmentHelper.environment.containsProperty(key);
    }

}
